﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace NeuroForecast
{
    /// <summary>
    /// Interaction logic for ProgressControl.xaml
    /// </summary>
    public partial class ProgressControl : UserControl
    {
        public String ActionCaption
        {
            set { tb_ActCaption.Text = value; }
            get { return tb_ActCaption.Text; }
        }

        public String ProgressDescriprion { set; get; }

        public ProgressControl()
        {
            InitializeComponent();
            
            Upd = new UpdatePbDel(UPBD);
        }

        private int _value = 0;
        public int Counter
        {
            set
            {
                _value = value;
                Dispatcher.Invoke(Upd, System.Windows.Threading.DispatcherPriority.Background, _value);
            }
            get { return _value; }
        }
        public delegate void UpdatePbDel(int value);

        public UpdatePbDel Upd;
        public void UPBD(int value)
        {
            progressBarEdit1.Value = value;
        }

        public void Activate(String caption, String description, double maximum)
        {
            progressBarEdit1.Maximum = maximum;
            Visibility = Visibility.Visible;
            ProgressDescriprion = description;
            ActionCaption = caption;
        }

        public void Deactivate()
        {
            Visibility = Visibility.Collapsed;
        }

        private void progressBarEdit1_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e)
        {
            tb_Progress.Text = ProgressDescriprion + ": " + progressBarEdit1.Value + " из " + progressBarEdit1.Maximum;
        }
    }
}
